import thenFs from 'then-fs'
const promiseArr = [
  thenFs.readFile('./files/3.txt', 'utf8'),
  thenFs.readFile('./files/2.txt', 'utf8'),
  thenFs.readFile('./files/1.txt', 'utf8')
]

// Promise.all所有异步操作全部结束后,才会执行then
Promise.all(promiseArr).then((result) => {
  console.log('result: ', result)
})

// Promise.race只要有任何一个异步操作完成,就执行then
Promise.race(promiseArr)
  .then((result) => {
    console.log(result)
  })
  .catch((err) => {
    console.log(err.message)
  })
